package interfazGrafica;

import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import main.GraphCity;

/**
 * Clase Intro: Intro deL Programa
 * 
 * @author  Grupo N11
 * @author  Prinsich Bernz, Emilio J. A.
 * @author 	Solia, Guillermo D.
 * @version  1.0
 */


public class Intro extends JFrame {

	private static final long serialVersionUID = 1L;
	private JLabel jLabel0;
	private JButton jButton0;
	private static Intro frame;
	private static final String PREFERRED_LOOK_AND_FEEL = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
	
	public Intro() {
		initComponents();
	}

	private void initComponents() {
		add(getJLabel0(), BorderLayout.CENTER);
		add(getJButton0(), BorderLayout.SOUTH);
		setSize(275, 385);
	}

	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Click AQUI para iniciar");
			jButton0.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent event) {
					GraphCity.changeWindow();

				}
			});
		}
		return jButton0;
	}

	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setIcon(new ImageIcon(getClass().getResource("/images/Intro.png")));
		}
		return jLabel0;
	}
	
	public static void exit(){
		frame.setVisible(false);
	}
	
	protected static void sendFrame(Intro frame2) {
		frame = frame2;
	}

	@SuppressWarnings("unused")
	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void run() {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				Intro frame = new Intro();
				frame.setDefaultCloseOperation(Intro.EXIT_ON_CLOSE);
				frame.setTitle("Welcome to GRAPH CITY");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
				frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/Graph City.png")));
				frame.setDefaultCloseOperation(Intro.DISPOSE_ON_CLOSE);
				frame.setResizable(false);
				sendFrame(frame);
			}
		});
	}
}
